package com.intre.open.gwtjpa.data.second.server.dao;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

import org.apache.log4j.Logger;

import com.intre.open.gwtjpa.data.first.server.dao.DataFirstDAO;
import com.intre.open.gwtjpa.data.second.domain.City;

public class DataSecondDAO {

	static final Logger logger = Logger.getLogger(DataFirstDAO.class);
	public final static String NAME = "dataSecondDAO";

	@PersistenceContext(unitName = "data_second_pu")
	protected EntityManager entityManager;

	protected void setEntityManager(EntityManager entityManager) {
		this.entityManager = entityManager;
	}

	protected EntityManager getEntityManager() {
		return entityManager;
	}

	@SuppressWarnings("unchecked")
	public List<City> loadAll() {
		Query query = getEntityManager().createQuery("FROM City");
		return (List<City>) query.getResultList();
	}

}
